package interview.huawei.tjt.training.huaweijishitiku;

import java.util.Scanner;

// 整数与IP地址间的转换
public class HJ33 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        while ( sc.hasNext() ) {

            // ip转10进制
            String strings1 = sc.next();
            String[] ip = strings1.split("\\.");
            if ( ip.length == 4 && Long.parseLong(ip[0]) < 256 && Long.parseLong(ip[1]) < 256 && Long.parseLong(ip[2]) < 256 && Long.parseLong(ip[3]) < 256 ) {
                System.out.println( Long.parseLong(ip[0]) << 24 | Long.parseLong(ip[1]) << 16 | Long.parseLong(ip[2]) << 8 | Long.parseLong(ip[3]) );
            } else {
                System.out.println( "IP序列不合法，请重新输入！" );
            }

            // 10进制转ip
            String strings2 = sc.next();
            long num = Long.parseLong(strings2);
            StringBuffer stringBuffer = new StringBuffer();
            stringBuffer.append( ( num >> 24 ) & 255 ).append( "." ).append( ( num >> 16 ) & 255 ).append( "." )
                    .append( ( num >> 8 ) & 255 ).append( "." ).append( num & 255 );
            System.out.println(stringBuffer.toString());
        }

    }

}
